package com.channelsoft.cm.application.tools;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;

public class Tools {
	
	public static boolean isNetworkAvialable(Context context){
		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		if(cm == null)  return  false;
		NetworkInfo[] ni = cm.getAllNetworkInfo();
		for(NetworkInfo info :ni){
			if(info.getState() == State.CONNECTED) return  true;
		}
		return false;
	}
	
	
	/*public static Drawable downImageByUrl(String imagePath) throws MalformedURLException, IOException{
		InputStream is = new URL(imagePath).openConnection().getInputStream();
		Drawable userIcon = Drawable.createFromStream(is, ".PNG");
		if(is != null){
			is.close();
		}
		return userIcon;
		
	}*/
}
